package com.proxy;

import java.util.Optional;

/**
 * @Author: YLBG-YCY-1325
 * @Description:
 * @Date: 2017/8/14
 */
public class SubjectProxy implements Subject{
    private Optional<RealSubject> subject = Optional.ofNullable(new RealSubject());

    @Override
    public void doSomething() {
        System.out.println("在doSomething之前的逻辑");
        subject.get().doSomething();
        System.out.println("在doSomething之后的逻辑");
    }

    public Optional<RealSubject> getSubject() {
        return subject;
    }

    public void setSubject(Optional<RealSubject> subject) {
        this.subject = subject;
    }
}
